Operator: SEL
The IEC operator is used for bitwise selection.
OUT := SEL(G, IN0, IN1)
means:
OUT := IN0;
if G = FALSE
OUT := IN1;
if G = TRUE
Permitted data types
IN0
, …, INn
and OUT
: any identical data type
Make sure that variables of the identical type are used at all three positions, especially when using user-defined data types. The compiler checks for type identity and returns any compile errors. The assignment of function block instances to interface variables is specifically not supported.
G
: BOOL
Important
When G is TRUE
, CODESYS does not compute an expression which precedes IN0
. When G
is FALSE
, CODESYS does not compute an expression which precedes IN1
.
Caution: In the case of graphical programming languages, the expressions at IN0
and IN1
are computed independently of the G
input when a Box, Jump, Return, Line Branch, or Edge Detection precedes.
ST
Var1 := SEL(TRUE,3,4); (* Result: 4 *)
FBD
